From: Rui Matos Date: Fri, 10 Oct 2014 13:54:30 +0000 (+0200) Subject: status/keyboard: Ensure we always have at least one input source X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~2034 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=72c6f0025d659466f00e54e4a6a6315d806cb1f3;p=gnome-shell.git status/keyboard: Ensure we always have at least one input source Most of the code handles the sources setting being empty and InputSourceManager.currentSource being null because previously the "model" (i.e. the sources list) was kept in gnome-settings-daemon. But this is fragile and since we're now the canonical place where the list lives we can force it to never be empty even if the gsetting is empty or contains only invalid entries. Adding the default keyboard layout in that case is the safest thing to do. https://bugzilla.gnome.org/show_bug.cgi?id=738303 --- diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 0c8454149..8cb8cc913 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -298,8 +298,7 @@ const InputSourceManager = new Lang.Class({ this._inputSources = {}; this._ibusSources = {}; - let inputSourcesByShortName = {}; - + let infosList = []; for (let i = 0; i < nSources; i++) { let displayName; let shortName; @@ -323,11 +322,24 @@ const InputSourceManager = new Lang.Class({ } } - if (!exists) - continue; + if (exists) + infosList.push({ type: type, id: id, displayName: displayName, shortName: shortName }); + } - let is = new InputSource(type, id, displayName, shortName, i); + if (infosList.length == 0) { + let type = INPUT_SOURCE_TYPE_XKB; + let id = KeyboardManager.DEFAULT_LAYOUT; + let [ , displayName, shortName, , ] = this._xkbInfo.get_layout_info(id); + infosList.push({ type: type, id: id, displayName: displayName, shortName: shortName }); + } + let inputSourcesByShortName = {}; + for (let i = 0; i < infosList.length; i++) { + let is = new InputSource(infosList[i].type, + infosList[i].id, + infosList[i].displayName, + infosList[i].shortName, + i); is.connect('activate', Lang.bind(this, this._activateInputSource)); if (!(is.shortName in inputSourcesByShortName))